<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

function add_drawing_tag($object_id, $tag) {
    if(!$object_id || strlen($tag) <=0)
        return FALSE;
    $time = time();
    $query = "INSERT INTO drawing_tags (object_id, tag, timestamp) 
                            VALUES('$object_id', '$tag', '$time')";
    return safe_insert_query($query);
}

function add_drawing_tags($object_id, $tags) {
    if(!$object_id || !is_array($tags) || strlen($tags[0]) <=0)
        return FALSE;
    $time = time();
    $tag = mysql_real_escape_string($tags[0]);
    $query = "INSERT INTO drawing_tags (object_id, tag, timestamp) 
                            VALUES('$object_id', '$tag', '$time')";
    for($index = 1; $index < count($tags); $index++) {
        $tag = mysql_real_escape_string($tags[$index]);
        $query .= ",('$object_id', '$tag', '$time')";
    }
    //echo $query;
    return safe_insert_query($query);
}

function get_drawing_tag($object_id) {
    $query = "SELECT tag FROM drawing_tags WHERE object_id = '$object_id' LIMIT 0, 1";
    $result = safe_select_query($query);
    return $result[0];
}

function get_drawing_tags($object_id) {
    $query = "SELECT tag FROM drawing_tags WHERE object_id = '$object_id'";
    $result = safe_select_query($query);
    return $result;
}

?>
